package com.gmss.crawler.job;

import com.gmss.crawler.task.IntegrityCaseTask;
import com.gmss.crawler.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 科研诚信定时任务
 */
@Slf4j
@Component
public class IntegrityCaseJob {

    @Resource
    private IntegrityCaseTask integrityCaseTask;

    /**
     * 每天0,9,18三个时间执行
     */
//    @Scheduled(cron = "0 0 0,9,18 * * ? ")
//    @Scheduled(cron = "0/10 * * * * ? ")
    public void sendMessageJob() {
        try {
            log.warn("科研诚信定时任务,执行时间：{}", DateUtils.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss"));
            integrityCaseTask.submit(null);
        } catch (Exception e) {
            log.error("发送消息异常，Exception[{}]",e);
        }
    }
}
